<template>
	<view class="uni-tab-bar">
		<scroll-view scroll-x>
			<view style="display: flex;">
				<block v-for="(tab,index) in tabBars" :key="tab.id">
					<view 
					class="swiper-tab-list" 
					:class="{'active':(tabIndex===index)}" 
					style="width: 50%;text-align: center;padding: 20rpx;"
					@tap="tabtap(index)">
						{{tab.name}} {{tab.num?tab.num:''}}
						<view class="swiper-tab-line"></view>
					</view>
				</block>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default{
		props:{
			tabBars:Array,
			tabIndex:Number
		},
		methods: {
			// tab点击事件
			tabtap(index) {
				this.$emit('tabtap',index)
				console.log(index)
			},
		}
	}
</script>

<style scoped>
	.uni-swiper-tab {
		border-bottom: 1upx solid #EEEEEE;
		display: flex;
	}
	
	.swiper-tab-list {
		color: #969696;
		font-weight: bold;
		background-color: #d9d9d9;
	}
	
	.uni-tab-bar .active {
		color: #343434;
		background-color: #FFFFFF;
	}
	
	.active .swiper-tab-line {
		background-color: rgb(141, 198, 63);
		border-bottom: 2rpx rgb(28, 187, 180);
		width: 90rpx;
		margin: auto;
		margin-top: 2rpx;
		border-top: 6rpx solid #1cbbb4;
		border-radius: 20rpx;
	}
</style>
